using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Simnova.Collaborate.Presenter;
using Simnova.Collaborate.View;


public partial class FeedbackSummary : System.Web.UI.Page, IFeedbackSummary
{
    FeedbackSummaryPresenter _feedbackSummaryPresenter;

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        _feedbackSummaryPresenter = new FeedbackSummaryPresenter(this, int.Parse(Request.QueryString["FeedbackId"].ToString()), int.Parse(Session["UserId"].ToString()));
    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    #region IFeedbackSummary Members

    decimal IFeedbackSummary.AverageRating
    {
        set { AverageRatingLabel.Text = value.ToString("0.00"); }
    }

    int IFeedbackSummary.Ratings
    {
        set { RatingsLabel.Text = value.ToString(); }
    }

    int IFeedbackSummary.Workarounds
    {
        set { WorkAroundsLabel.Text = value.ToString(); }
    }

    bool IFeedbackSummary.WatchingFeedback
    {
        set
        {
            if (value)
            {
                WatchListLabel.Text = "You are currently watching this issue.";
            }
            else
            {
                WatchListLabel.Text = "You are not currently watching this issue.";
            }
        }
    }

    string IFeedbackSummary.Title
    {
        set { TitleLabel.Text = value; }
    }

    string IFeedbackSummary.Description
    {
        set { DescriptionLabel.Text = value; }
    }

    DateTime IFeedbackSummary.CreateDate
    {
        set { CreateDateLabel.Text = value.ToShortDateString(); }
    }

    IList IFeedbackSummary.Comments
    {
        set { 
            CommentsDataList.DataSource = value;
            CommentsDataList.DataBind();
        }
    }

    string IFeedbackSummary.Comment
    {
        get { return CommentTextBox.Text; }
        set { CommentTextBox.Text = value; }
    }

    #endregion

    protected void WatchListLinkButton_Click(object sender, EventArgs e)
    {
        _feedbackSummaryPresenter.SetWatchingFeedback();
    }

    protected void VoteNowLinkButton_Click(object sender, EventArgs e)
    {
        Response.Redirect(@"FeedbackRating.aspx?FeedbackId=" + Request.QueryString["FeedbackId"].ToString());
    }
    protected void SaveCommentButton_Click(object sender, EventArgs e)
    {
        _feedbackSummaryPresenter.SaveComment();
    }
    protected void WorkaroundsLinkButton_Click(object sender, EventArgs e)
    {
        Response.Redirect(@"FeedbackWorkaround.aspx?FeedbackId=" + Request.QueryString["FeedbackId"].ToString());
    }
}
